package com.runen.infinitemovement.activity;

import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.runen.infinitemovement.R;
import com.runen.infinitemovement.adapter.LastTeamGroupAdapter;
import com.runen.infinitemovement.base.BaseActivity;
import com.runen.infinitemovement.model.entity.DepartmentsEntity;
import com.runen.rxnetlibrary.utils.JsonUtils;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class LastTeamGroupActivity extends BaseActivity {

    @BindView(R.id.top_btn_left)
    Button topBtnLeft;
    @BindView(R.id.top_title)
    TextView topTitle;
    @BindView(R.id.rv_last_team_group)
    RecyclerView rvLastTeamGroup;
    private LastTeamGroupAdapter lastTeamGroupAdapter;
    private DepartmentsEntity departmentsEntity;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_last_team_group;
    }

    @Override
    protected void initView(@Nullable Bundle savedInstanceState) {
        ButterKnife.bind(this);
        departmentsEntity = JsonUtils.fromJson(getIntent().getStringExtra("NEXT_TEAM_INFO"), DepartmentsEntity.class);
        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        rvLastTeamGroup.setLayoutManager(layoutManager);
        lastTeamGroupAdapter = new LastTeamGroupAdapter(this);
        rvLastTeamGroup.setAdapter(lastTeamGroupAdapter);
        if (departmentsEntity != null) {
            topTitle.setText(departmentsEntity.name);
            lastTeamGroupAdapter.setNewData(departmentsEntity.staffs);
        }
    }

    @OnClick(R.id.top_btn_left)
    public void onViewClicked() {
        finish();
    }
}
